// 动态路由配置页面
import { asyncRoutes, constantRoutes } from '@/router/index'

export default {
  namespaced: true,
  state: {
    routes: [] // 筛选过后具有访问权限的的路由
  },
  mutations: {
    setRoutes(state, routes) {
      state.routes = [...constantRoutes, ...routes]
    }
  },
  actions: {
    filterRoutes(store, menus) {
      const routes = asyncRoutes.filter(v => menus.includes(v.code))
      store.commit('setRoutes', routes)
      return routes
    }
  }
}
